/* 
 * File:   ucgrid3d.h
 * Author: oddi
 *
 * Created on November 18, 2010, 7:37 PM
 */

#ifndef _UCGRID3D_H
#define	_UCGRID3D_H

#include "inc/core/global_definitions.h"
#include "inc/core/poisson1d.h"
#include "inc/core/ebsources.h"
#include "inc/core/particles.h"
#include "cuda.h"
#include "cuda_runtime_api.h"

#ifdef	__cplusplus
extern "C" {
#endif


#define BLOCK_SIZE (64)

    typedef struct struct_ucgrid3d {
        struct cudaPitchedPtr rho; //3d array
        struct cudaPitchedPtr phi; //3d array
        int Nx;
        int Ny;
        int Nz;
        floatdig dx;
        floatdig dy;
        floatdig dz;
        poisson1d* poisson_solvers;
    } ucgrid3d;

    __host__ ucgrid3d* ucgrid3d_init_grid(ucgrid3d* grid, int Nx, int Ny, int Nz,
                            floatdig dx, floatdig dy, floatdig dz);
    __host__ void ucgrid3d_weight_particles_rho(particles_set* set, ucgrid3d* grid);
    __host__ void ucgrid3d_free_grid(ucgrid3d* grid);
    __host__   void ucgrid3d_get_cell_pos(ucgrid3d* grid, npos3d* n, pos3d* p);
    __host__   void ucgrid3d_get_neighbour_cells(ucgrid3d* grid, pos3d* ppos, npos3d* lc, npos3d* rc);
    __host__   void ucgrid3d_get_full_size_of_system(ucgrid3d*, pos3d*);


    void ucgrid3d_dump_rho_into_file(ucgrid3d*, char* homedir, char* filename);


#ifdef	__cplusplus
}
#endif

#endif	/* _UCGRID3D_H */
